package com.android.pagemarket.ui.widget;

import android.content.Context;
import android.text.Html;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.pagemarket.R;
import com.android.pagemarket.io.protocol.out.QueryList.OrderItem;
import com.android.pagemarket.ui.activity.query.OrderDetailActivity;

/*********************************************************
 * @author : zhaohua
 * @version : 2012-11-13
 * @see : 订单查询结果列表视图
 * @Copyright : copyrights reserved by personal 2007-2011
 **********************************************************/
public class OrderItemView extends LinearLayout implements OnClickListener
{
    
    private TextView order_num;
    private TextView order_statu;
    private TextView order_degree;
    
    private OrderItem data;
    
    public OrderItemView(Context context)
    {
        this(context,null);
    }
  
    public OrderItemView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        View row = inflate(getContext(), R.layout.listitem_order, null);
        addView(row,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
        initViews();
    }
    
    private void initViews()
    {
        order_num = (TextView)findViewById(R.id.order_num);
        order_statu = (TextView)findViewById(R.id.order_statu);
        order_degree = (TextView)findViewById(R.id.order_degree);
    }
    
    public void bindData(OrderItem item)
    {
        data = item;
        
        order_num.setText(item.oid +"");
        order_statu.setText(item.status);
        order_degree.setText(Html.fromHtml(item.paperType+"/"+ item.degree+"&quot;"));
        setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
        OrderDetailActivity.startActivity(getContext(), data.oid);
    }

    public void setHeadable(boolean allable)
    {
        order_num.setTextColor(getResources().getColor(R.color.header_color));
        order_statu.setTextColor(getResources().getColor(R.color.header_color));
        order_degree.setTextColor(getResources().getColor(R.color.header_color));        
    }
}
